﻿using Shake.Framework.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shake.Framework.Utility
{
    public class EnumUtil
    {
        public static IEnumerable<NameValueContent> GetNameValues(Type enumType)
        {
            var values = Enum.GetValues(enumType);
            foreach (var value in values)
            {
                var result = new NameValueContent { Name = value.ToString(), Value = Convert.ToInt32(value) };
                yield return result;
            }
        }

        public static string GetEnumJson(Type enumType)
        {
            var datas = GetNameValues(enumType);
            return fastJSON.JSON.ToJSON(datas);
        }
    }
}
